package com.panda.mall.user.level.controller;

import com.panda.mall.common.mallUser.entity.MallUserLevel;
import com.panda.mall.common.result.Result;
import com.panda.mall.user.level.service.MallUserLevelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * author: tcy
 * createDate: 2023/6/13
 * description: 商城用户等级
 */
@Api(tags = "商城账户等级")
@RestController
@RequestMapping("/user")
public class MallUserLevelController {

    @Autowired
    MallUserLevelService mallUserLevelService;

    @ApiOperation(value = "新增或修改商城等级", notes = "新增或修改商城等级")
    @PostMapping("/level/saveOrUpdateLevel")
    public Result<String> saveOrUpdateLevel(@RequestBody MallUserLevel mallUserLevel) {
        return Result.success(mallUserLevelService.saveOrUpdateLevel(mallUserLevel));
    }

    @ApiOperation(value = "查询全部商城等级", notes = "查询全部商城等级")
    @GetMapping("/level/queryList")
    public Result<List<MallUserLevel>> queryList() {
        return Result.success(mallUserLevelService.queryList());
    }

    @ApiOperation(value = "查询商城等级详情", notes = "查询商城等级详情")
    @GetMapping("/level/queryLevelById/{id}")
    public Result<MallUserLevel> queryLevelById(@PathVariable("id") Long id) {
        return Result.success(mallUserLevelService.queryLevelById(id));
    }

    @ApiOperation(value = "删除商城等级", notes = "删除商城等级")
    @PostMapping("/level/deleteLevel")
    public Result<String> deleteLevel(@RequestBody List<Long> ids) {
        return Result.success(mallUserLevelService.deleteLevel(ids));
    }
}
